//
//  UIImage+YDYExtention.m
//  DY_Bilibili
//
//  Created by 杨德勇 on 2016/9/23.
//  Copyright © 2016年 杨德勇. All rights reserved.
//

#import "UIImage+YDYExtention.h"

@implementation UIImage (YDYExtention)

-(instancetype)ydy_circleImage{
    UIGraphicsBeginImageContext(self.size);
    
    CGContextRef ref = UIGraphicsGetCurrentContext();
    
    CGRect rect = CGRectMake(0, 0, self.size.width, self.size.height);
    //加圆
    CGContextAddEllipseInRect(ref, rect);
    
    CGContextClip(ref);
    
    [self drawInRect:rect];
    
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    
    UIGraphicsEndImageContext();
    
    return image;
    
}
@end
